package com.zking.ssm.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zking.ssm.sys.mapper.HotelBrandMapper;
import com.zking.ssm.sys.model.HotelBrand;
import com.zking.ssm.sys.model.HotelBrandProduct;
import com.zking.ssm.sys.model.HotelSellerEmployee;
import com.zking.ssm.sys.service.IHotelBrandService;
import com.zking.ssm.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotelBrandServiceImpl implements IHotelBrandService {
   @Autowired
   private HotelBrandMapper hotelBrandMapper;

   public HotelBrandServiceImpl(){

   }
    @Override
    public int deleteByPrimaryKey(Long id) {
        return hotelBrandMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(HotelBrand record) {
        return hotelBrandMapper.insert(record);
    }

    @Override
    public int insertSelective(HotelBrand record) {
        return hotelBrandMapper.insertSelective(record);
    }

    @Override
    public HotelBrand selectByPrimaryKey(Long id) {
        return hotelBrandMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(HotelBrand record) {
        return hotelBrandMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(HotelBrand record) {
        return hotelBrandMapper.updateByPrimaryKey(record);

    }

    @Override
    public List<HotelBrand> list(HotelBrand record, PageBean pageBean) {

       return hotelBrandMapper.list(record);
    }

    @Override
    public List<HotelBrandProduct> listall(HotelBrandProduct record, PageBean pageBean) {
        if (null != pageBean && 0 != pageBean.getRows()) {
            PageHelper.startPage(pageBean.getPage(), pageBean.getRows());
        }
        List<HotelBrandProduct> list = hotelBrandMapper.listall(record);
        if (null != pageBean && 0 != pageBean.getRows()) {
            PageInfo pageInfo = new PageInfo(list);
            pageBean.setTotal(pageInfo.getTotal() + "");
        }
        return list;
    }
}
